<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no"/>

    <title>登录</title>
    <style>
        .header {
            height: 59px;
            border-bottom: 1px solid #c42e2e;
            background-color: #c42e2e;
        }

        .header .layui-nav {
            position: absolute;
            right: 0;
            top: 0;
            padding: 0;
            background: none;
        }

        .header p {
            font-size: x-large;
            color: #fff;
            position: absolute;
            left: 20px;
            top: 13px;
        }
    </style>
    <#include "_css.ftl">
</head>
<body class="layui-layout-body">
<div class="layui-header header header-doc" summer="">

    <p style="font-size-adjust: inherit;">远联公益系统</p>
</div>
<div class="layadmin-tabspage-none">
    <div class="layadmin-user-login layadmin-user-display-show" style="display: none;">
        <div class="layadmin-user-login-main">
            <div class="layui-tab  layui-tab-brief">
                <ul class="layui-tab-title">
                    <li class="layui-this">导师登录</li>
                    <li>家长登录</li>
                    <li>学生登录</li>
                </ul>
                <div class="layui-tab-content">
                    <div class="layui-tab-item layui-show">
                        <div class="layadmin-user-login-box layadmin-user-login-body layui-form">
                            <form action="/login" method="post">
                                <div class="layui-form-item">
                                    <label class="layadmin-user-login-icon layui-icon layui-icon-username"
                                           for="LAY-user-login-username"></label>
                                    <input type="text" name="username" id="LAY-user-login-username"
                                           lay-verify="required" placeholder="用户名" class="layui-input">
                                </div>
                                <div class="layui-form-item">
                                    <label class="layadmin-user-login-icon layui-icon layui-icon-password"
                                           for="LAY-user-login-password"></label>
                                    <input type="password" name="pwd" lay-verify="required"
                                           placeholder="密码" class="layui-input">
                                </div>
                                <input type="hidden" name="role" value="0">
                                <div class="layui-form-item">
                                    <button class="layui-btn layui-btn-fluid" lay-submit lay-filter="*" type="submit">登
                                        入
                                    </button>
                                </div>
                            </form>
                        </div>
                    </div>
                    <div class="layui-tab-item">
                        <div class="layadmin-user-login-box layadmin-user-login-body layui-form">
                            <form action="/login" method="post">
                                <div class="layui-form-item">
                                    <label class="layadmin-user-login-icon layui-icon layui-icon-username"
                                           for="LAY-user-login-username"></label>
                                    <input type="text" name="username" id="LAY-user-login-username"
                                           lay-verify="required" placeholder="用户名" class="layui-input">
                                </div>
                                <div class="layui-form-item">
                                    <label class="layadmin-user-login-icon layui-icon layui-icon-password"
                                           for="LAY-user-login-password"></label>
                                    <input type="password" name="pwd" lay-verify="required"
                                           placeholder="密码" class="layui-input">
                                </div>
                                <input type="hidden" name="role" value="1">
                                <div class="layui-form-item">
                                    <button class="layui-btn layui-btn-fluid" lay-submit lay-filter="*" type="submit">登
                                        入
                                    </button>
                                </div>
                            </form>
                        </div>
                    </div>
                    <div class="layui-tab-item">
                        <div class="layadmin-user-login-box layadmin-user-login-body layui-form">
                            <form action="/login" method="post">
                                <div class="layui-form-item">
                                    <label class="layadmin-user-login-icon layui-icon layui-icon-username"
                                           for="LAY-user-login-username"></label>
                                    <input type="text" name="username" id="LAY-user-login-username"
                                           lay-verify="required" placeholder="用户名" class="layui-input">
                                </div>
                                <div class="layui-form-item">
                                    <label class="layadmin-user-login-icon layui-icon layui-icon-password"
                                           for="LAY-user-login-password"></label>
                                    <input type="password" name="pwd" lay-verify="required"
                                           placeholder="密码" class="layui-input">
                                </div>
                                <input type="hidden" name="role" value="2">
                                <div class="layui-form-item">
                                    <button class="layui-btn layui-btn-fluid" lay-submit lay-filter="*" type="submit">登
                                        入
                                    </button>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>

        </div>
    </div>
</div>

<#include "_js.ftl">
<script>


    $(function () {
        //注意：选项卡 依赖 element 模块，否则无法进行功能性操作
        layui.use(['form', 'element', 'layer'], function () {
            var form = layui.form
            form.on('submit(*)', function (data) {
                $.ajax({
                    url: data.form.action,
                    type: 'POST',
                    data: data.field,
                    dataType: 'json',
                    success: function (res) {
                        if (res.code === 0) {
                            layer.msg('登录成功！');
                            if (res.data === 0)
                                window.location.href = '/main';
                            else if (res.data === 1)
                                window.location.href = '/main';
                            else
                                window.location.href = '/student_index';
                        } else {
                            layer.msg(res.msg)
                        }
                    },
                    error: function (res) {
                        console.log(res);
                    }
                });
                return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
            });
        });


    })

</script>
</body>
</html>